package cn.jtfadmin.cms.domain.dto;

import lombok.Data;
import org.springframework.util.CollectionUtils;

import java.io.Serializable;
import java.util.List;

/**
 * cms 一级菜单信息
 * @author jtf
 * @since 0.0.2
 */
@Data
public class CmsPageTopMenuDTO extends CmsPageMenuDTO implements Serializable {






    /**
     *
     */
    protected boolean showChildrenMenu;



    public void setShowChildrenMenu(boolean showChildrenMenu){
        this.showChildrenMenu = showChildrenMenu;
        if(showChildrenMenu && current && !CollectionUtils.isEmpty(children)){
            setStyle( "active dropdown");
        }else if(showChildrenMenu && !current && !CollectionUtils.isEmpty(children)){
            setStyle("dropdown");
        }else {
            setStyle(current? "active":"");
        }
    }

    public void setCurrent(boolean current){
        this.current = current;
        if(showChildrenMenu && current && !CollectionUtils.isEmpty(children)){
            setStyle( "active dropdown");
        }else if(showChildrenMenu && !current && !CollectionUtils.isEmpty(children)){
            setStyle("dropdown");
        }else {
            setStyle(current? "active":"");
        }
    }

}
